package com.guimin.wallet.api;



import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.guimin.common.vo.R;
import com.guimin.user.api.UserInfoApi;
import com.guimin.user.dto.LoginInfoDto;
import com.guimin.wallet.entity.GuiminWallet;
import com.guimin.wallet.service.GuiminWalletService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 钱包信息表(GuiminWallet)控制层
 *
 * @author makejava
 * @since 2021-11-30 15:18:58
 */
@RestController
@RequestMapping("wallet")
public class GuiminWalletApi {
    /**
     * 服务对象
     */
    @Resource
    private GuiminWalletService guiminWalletService;
    @Resource
    private UserInfoApi userInfoApi;

    /**
     * 获取我的钱包信息
     * @param request
     * @return
     */
    @GetMapping("/get/info")
    public R<GuiminWallet> getWalletInfo(HttpServletRequest request) {
        LoginInfoDto login = userInfoApi.getLogin(request);
        GuiminWallet wallet = guiminWalletService.getOne(new LambdaQueryWrapper<GuiminWallet>()
                .eq(GuiminWallet::getUserId, login.getId())
        );
        return R.success(null,wallet);
    }
}

